<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class select_vehicle_reminder extends Page
{
       public $Image2 = null;
       public $btnSearch = null;
       public $edtSearch = null;
       public $Image4 = null;
       public $hfStyle = null;
       public $btn1 = null;
       public $btnSubmit = null;
       public $hfVehId = null;
       public $hfPlate = null;
       public $JTJavaScript1 = null;
       public $JTVehicleList = null;
       public $JTSiteTheme1 = null;

       function btn1JSClick($sender, $params)
       {

       ?>
       alert('1');
       var veh_id = document.getElementById('hfVehId').value;
       var veh_num = document.getElementById('hfPlate').value;
       var style = document.getElementById('hfStyle').value;
       alert('2');
       alert(veh_id+'xxx'+veh_num+'yyy'+style);
       <?php

       }

       function btnSubmitJSClick($sender, $params)
       {

       ?>
       var veh_id = document.getElementById('hfVehId').value;
       var veh_num = document.getElementById('hfPlate').value;
       var style_id = document.getElementById('hfStyle').value;

        var win_height = 450;
        var win_width = 600;
        var height = window.opener.outerHeight;
        var width = window.opener.outerWidth;
        var top = Math.round((height-win_height)/2);
        var left = Math.round((width-win_width)/2);

       //window.opener.document.getElementById('lblVehicle').innerHTML = "<span style='color:red;cursor:pointer' onclick=window.open('select_vehicle_report.php','window_select_vehicle','location=no,height="+win_height+",width="+win_width+",top="+top+",left="+left+"')>Vehicle: "+veh_num+"</span>";
       //window.opener.document.getElementById('hfAllOrSelect').value = veh_id;
       //window.close();
       window.opener.document.getElementById('lblVeh').innerHTML = "<span style='color:blue;cursor:pointer' onclick=window.open('select_vehicle_reminder.php','window_select_vehicle','location=no,height="+win_height+",width="+win_width+",top="+top+",left="+left+"')>Vehicle: "+veh_num+"</span>";
       window.opener.document.getElementById('JTFrameReminders').src = 'set_veh_reminder_list.php?veh='+veh_id+'&style='+style_id;
       window.close();
       <?php

       }

       function JTVehicleListShow($sender, $params)
       {
       $query_veh = "SELECT * FROM vehicle_tbl WHERE company_id='".$_SESSION['company_id']."' AND
       (veh_num LIKE '%".$this->edtSearch->Text."%' OR
       year LIKE '%".$this->edtSearch->Text."%' OR
       manufacturer_name LIKE '%".$this->edtSearch->Text."%' OR
       model_name LIKE '%".$this->edtSearch->Text."%'
       )";
       $result_veh = mysql_query($query_veh) or die("SELECT VEHICLES ".mysql_error());

       $arr_veh = array();
       while($row_veh = mysql_fetch_array($result_veh))
       {
        $radio = "<input name=radioVeh type=radio onclick=setHidden('".$row_veh['vehicle_id']."','".$row_veh['veh_num']."','".$row_veh['style_id']."')></input>";
        $arr_veh[] = array(
        'Plate'=>$radio." ".$row_veh['veh_num'],
        'Year'=>$row_veh['year'],
        'Make'=>$row_veh['manufacturer_name'],
        'Model'=>$row_veh['model_name']
        );
       }
       $this->JTVehicleList->setCellData($arr_veh);


       }

       function select_vehicle_reminderCreate($sender, $params)
       {
       //$_SESSION['company_id'] = '1';
       $this->edtSearch->setText($_GET['search']);
       }

       function btnSearchClick($sender, $params)
       {
       redirect('set_select_vehicle_reminder.php?search='.$this->edtSearch->Text);
       }

       function edtSearchJSClick($sender, $params)
       {

       ?>
       document.getElementById('edtSearch').value = '';
       <?php

       }
}

global $application;

global $select_vehicle_reminder;

//Creates the form
$select_vehicle_reminder=new select_vehicle_reminder($application);

//Read from resource file
$select_vehicle_reminder->loadResource(__FILE__);

//Shows the form
$select_vehicle_reminder->show();

?>